package com.aimaterials;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;

public class ZipTest {

    public static void main(String[] args) throws IOException {

        ZipTest.abc("d:/1.zip");

    }


    public static void abc(String path) throws IOException {
        ZipFile zf = new ZipFile(path);
        InputStream in = new BufferedInputStream(new FileInputStream(path));
        Charset gbk = Charset.forName("gbk");
        ZipInputStream zin = new ZipInputStream(in,gbk);
        ZipEntry ze;
        while((ze = zin.getNextEntry()) != null){
//            if(ze.toString().endsWith("MP4")){
//                String aaa = ze.toString().substring(ze.toString().indexOf("."),ze.toString().length());
//                System.out.println(aaa);
//            }
            if(!ze.isDirectory()){
                String aaa = ze.toString().substring(ze.toString().lastIndexOf("."),ze.toString().length());
                System.out.println(aaa);
            }

        }
        zin.closeEntry();
    }
}
